@extends('layouts._app')
@section('content')
    <style>
        img {
            max-height: 100px;
            max-width: 100px;
        }
    </style>
    <body class="iframe-h">
    <div class="email-write">
        @include('layouts._flash')
        <div class="layui-form-item">
            <label class="layui-form-label">邮箱：</label>
            <div class="layui-input-block">
                {!! Form::text('',"{$email->sender}",['readonly','class'=>'layui-input']) !!}
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">名称：</label>
            <div class="layui-input-block">
                {!! Form::text('',"{$email->name}",['readonly','class'=>'layui-input']) !!}
            </div>
        </div>
        @if($request['title'] == 'EmailSend')
            <div class="layui-form-item">
                <label class="layui-form-label">收件人地址：</label>
                <div class="layui-input-block">
                    {!! Form::text('',"{$email->receipt}",['readonly','class'=>'layui-input']) !!}
                </div>
            </div>
        @endif
        <div class="layui-form-item">
            <label class="layui-form-label">标题：</label>
            <div class="layui-input-block">
                {!! Form::text('',"{$email->title}",['readonly','class'=>'layui-input']) !!}
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">内容：</label>
            <div class="layui-input-block">
                <iframe id="container" name="iframe2" src="{{$email->url}}"
                        onload="this.height=iframe2.document.body.scrollHeight"
                        width="100%" frameborder="0">
                </iframe>
            </div>
        </div>
        @if(isset($file) && !empty($file))
            <div class="layui-form-item">
                <label class="layui-form-label"><b>附件：</b></label>
                <div class="layui-input-block">
                    <div style="padding: 5px;">(<span>{{count($file)}}</span> 个)
                        <a style="margin: 0 0 0 20px;"
                           href="{{route('expansion.email.AllDownload')}}?id={{$email->file}}">全部下载</a>
                    </div>
                    @foreach($file as $value)
                        <div style="padding: 5px;position: relative;min-height: 135px;">
                            <a href="javascript:;">
                                <img src="{{assetImage($value->url)}}" alt="{{$value->name}}">
                            </a>
                        </div>
                        <div style="position: absolute;margin: -100px 0 0 145px;">
                            <span href="javascript:;" style="padding: 5px;">{{$value->name}}</span><span
                                style="color: #a0a0a0;">({{$value->size}})</span>
                            <br>
                            <a href="{{route('expansion.email.download')}}?id={{$value->id}}"
                               style="margin: 5px;">下载</a>
                        </div>
                    @endforeach
                </div>
            </div>
        @endif
        <div class="layui-form-item">
            <a href="{{route('expansion.email.index')}}?title={{$request['title']}}&name={{$request['name']}}&page={{$request['page']}}"
               class="layui-btn layui-btn-primary"><i class="layui-icon">&#x1006;</i>
                放弃</a>
        </div>
    </div>
    <script src="{{asset('static/admin/layui/layui.js')}}" type="text/javascript" charset="utf-8"></script>
    <script src="{{asset('js/jquery.min.js')}}" type="text/javascript" charset="utf-8"></script>
    <script>
        layui.use(['form'], function () {
            var form = layui.form();

            form.on('select(category)', function (e) {
                if (e.value == '下载') {
                    return false;
                }
                /**
                 * 写入文件下载
                 * @param id
                 */
                var table = $("#change_category").data('id');
                var ext = e.value;
                dialog.confirm({
                    message: '这可能会耗费很长时间！是否继续',
                    success: function () {
                        window.open('{{route('TextFile')}}' + '?table=' + table + '&ext=' + ext, '_parent');
                        window.location.reload();
                    },
                });
            });
            form.render();
        });

    </script>
    </body>
@endsection
